using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
//using System.Drawing;
using System.Linq;
using System.Text;
//using System.Windows.Forms;
using INI;
using System.Windows.Forms;


namespace myCommon.WinForm
{



    /// <summary>有关WinForm控件的一些功能，放在这里
    /// </summary>
    public static partial class WinFormFunc
    {
        /// <summary> 把INIPath里的内容提取到combox里
        /// </summary>
        /// <param name="QtyType">combo总数的字段名，对应的数量名称</param>
        /// <param name="SectionName">itemlist内容保存的段名</param>
        /// <param name="cb">要提取的combox</param>
        public static void INIToCombo(string QtyType, string SectionName, ComboBox cb, string INIPath)
        {
            int i;
            int Qty;
            string sTemp;
            INIClass iniConfig = new INIClass(INIPath);
            Qty = iniConfig.IniReadValue("General", QtyType, 0);
            cb.Items.Clear();
            for (i = 0; i < Qty; i++)
            {
                sTemp = iniConfig.IniReadValue(SectionName, i.ToString(), "");
                cb.Items.Add(sTemp);
            }
            cb.Text = iniConfig.IniReadValue(SectionName, "Last" + SectionName, "");
        }

        /// <summary> 把combox里的内容存入INIPath里，数量保存在INIPath的SectionName段
        /// </summary>
        /// <param name="QtyType">General段，对应的数量名称</param>
        /// <param name="SectionName">itemlist内容保存的段名</param>
        /// <param name="cb">要提取的combox</param>
        public static void ComboToINI(string QtyType, string SectionName, ComboBox cb, string INIPath)
        {
            int i;
            INIClass iniConfig = new INIClass(INIPath);

            iniConfig.IniWriteValue("General", QtyType, cb.Items.Count.ToString());
            for (i = 0; i < cb.Items.Count; i++)
            {
                iniConfig.IniWriteValue(SectionName, i.ToString(), cb.Items[i].ToString());
            }
            iniConfig.IniWriteValue(SectionName, "Last" + SectionName, cb.Text);
        }
    }

 



}